package com.xusheng.cli.tools;


import com.xusheng.cli.common.base.ProxyInfoForSession;
import com.xusheng.cli.common.constant.Constant;

/**
 * @author jy
 * @since 2021-11-02 13:28
 */
public class CurrentProxyUserUtil {

    public static ProxyInfoForSession getCurrentUser() {
        return StpProxyUtil.isLogin() ? (ProxyInfoForSession) StpProxyUtil.getSession(false).get(Constant.PROXY) : null;
    }

    public static Long getUserId() {
        try {
            return StpProxyUtil.getLoginIdAsLong();
        } catch (Exception e) {
            return 0L;
        }
    }

    public static String getAccount() {
        ProxyInfoForSession currentUser = getCurrentUser();
        return currentUser != null ? currentUser.getAccount() : null;
    }

}
